package kyssion.leetcode.num101_150;

public class code121_买股票的最佳时机 {
    public int maxProfit(int[] prices) {
        if(prices.length==0){
            return 0;
        }
        int max = Integer.MIN_VALUE;
        int index = 0;
        for (int a = 0; a < prices.length; a++) {
            if(prices[index]>prices[a]){
                index=a;
                continue;
            }else{
                max = Math.max(max,prices[a]-prices[index]);
            }
        }
        return max;
    }
}
